package net.maku.module.organization.vo;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fhs.core.trans.anno.Trans;
import com.fhs.core.trans.constant.TransType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import net.maku.framework.common.utils.TreeNode;
import net.maku.module.business.entity.DictionariesSubsetEntity;
import org.apache.commons.lang3.StringUtils;

/**
 * 业务_组织
 *
 * @author
 */
@Data
@Schema(description = "业务_组织")
public class OrganizationVO extends TreeNode<OrganizationVO> {

    private static final long serialVersionUID = 1L;

    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @Schema(description = "主键")
    private Long id;

    @Schema(description = "名称")
    private String name;

    @Schema(description = "编码")
    private String code;

    @Trans(type = TransType.SIMPLE, target = DictionariesSubsetEntity.class, fields = {"name"}, refs = {"typeName"})
    @Schema(description = "类型")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long typeId;

    @Schema(description = "类型名称")
    private String typeName;

    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @Schema(description = "上级部门")
    private Long superiorId;

    @Schema(description = "上级负责人")
    private String superiorPrincipal;

    @Schema(description = "简称")
    private String abbreviation;

    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @Schema(description = "工作地点")
    private Long workplaceId;

    @Schema(description = "工作城市")
    private String workplaceStr;

    @Schema(description = "编制人数")
    private String population;

    @Schema(description = "是否启用")
    private Integer isEnable;

    @Schema(description = "组织描述")
    private String description;

    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @Schema(description = "上级id")
    private Long pid;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "组织机构图 名称")
    private String label;

    @Schema(description = "组织机构图 样式")
    private JSONObject style;



    public Long getPid() {
        return superiorId;
    }

    public String getLabel() {
        return name;
    }

    public JSONObject getStyle() {
        JSONObject jsonObject = new JSONObject();
        if (StringUtils.isNotBlank(remark)) {
            jsonObject = JSONObject.parseObject(remark);
        }

        return jsonObject;
    }
}